<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="/WEB-INF/jsp/includes.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>人民币大写转换1</title>
<style type="text/css">
* {margin:0px;padding:0px;font-family:"Courier New", Courier, monospace,"宋体";font-size:12px;color:#333;}
input {outline:none;}
a:link {text-decoration: none;}
a:visited {text-decoration: none;}
a:hover {text-decoration: none;}
a:active {text-decoration: none;}
input {height:20px;width:180px;padding-left:2px;*line-height:150%;border:1px solid #B7CAE5;}
#forex {position:relative;margin:0px auto;width:540px;padding-top:10px;background:#dba869 url(<c:url value="/images/app/qihoo/moneyChange/woodbgb.jpg"/>) repeat-y 0 0;}
#forex_title {height:55px;width:464px;}
#forex_main {width:464px;}
.forex_cup {padding-bottom:10px;/*background:url(images/cup.png) no-repeat right bottom;*/}
#forex_cp {width:473px;height:auto;margin:0 auto;background:url(<c:url value="/images/app/qihoo/moneyChange/bg4.png"/>) no-repeat;
_background:none;
_filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="<c:url value="/images/app/qihoo/moneyChange/bg4.png"/>" ,sizingMethod="crop");}
.forex_container {position:relative;width:473px;height:auto;}
.forex_line {width:100%;height:40px;clear:both;}
.forex_line div {float:left;margin-left:10px;line-height:200%;}
.forex_line div span {margin-left:22px;}
.forex_line div font {margin:0px;padding:0px;color:#999;}
.forex_line div label {color:#c00;font-family:arial;font-weight:bold;}
.selectorCss {cursor:pointer;width:156px;height:26px;margin:0px;padding:0px;}
.selectorCss a {background:url(images/selector.png) no-repeat 0 0;width:156px;height:26px;display:block;*line-height:210%;}
.selectorCss a span {margin-left:12px;color:#666;}/*#3A629A*/

.selectorCss input {border:0px;margin:0px;color:#666;background:url(images/selector.png) no-repeat 0 0;width:156px;height:20px;*height:26px;display:block;*margin-left:-10px;cursor:default;font-size:12px;outline:none;padding:4px 0px 2px 10px;*padding:4px 0px 2px 10px !important;padding:7px 0px 2px 10px\0;}

.spaceCss {height:20px;}
.spaceCss2 {width:100px;*width:115px;}
.spaceCss3 {height:60px;}
.menuCss {position:absolute;margin:0px;padding:0px;left:0px;top:0px;border:1px solid #B7CAE5;background:#F8F9FC;width:152px;height:200px;overflow:auto;overflow-x:hidden;display:none;}
.menuCss div {width:156px;height:25px;text-align:left;cursor:default;background:#F8F9FC;line-height:200%;}
.menuCss div span {margin-left:5px;}
.forex_simple_txt {color:#3A629A;}
.forex_txt {color:#333;}
.bottom{text-align:center;}
#arrowPanel {position:absolute;left:280px;*+left:295px;_left:305px;top:132px;}
#arrowPanel a {display:block;width:22px;height:30px;background:url(images/arrow1.png) no-repeat 0 0;}
.silderPanel {position:absolute;left:315px;*left:325px;top:132px;display:none;border:1px solid #FFF27D;padding:0px 5px;background-color:#FFFCDE;line-height:200%;}
#msgPanel {top:73px;}
.forex_cup_on {position:absolute;width:108px;height:191px;background:url(<c:url value="/images/app/qihoo/moneyChange/cup.png"/>) no-repeat 0 0;z-index:3;right:0px;top:190px;
_background:none;
_filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="<c:url value="/images/app/qihoo/moneyChange/cup.png"/>" ,sizingMethod="crop");}
</style>
<script type="text/javascript" src="<c:url value='/js/jquery-1.4.2.min.js'/>"></script>
<script type="text/javascript">
$(function() {
	$("#money_in").keyup(function(event){
/*  		alert(event.keyCode);
		if(event.keyCode==8){
			alert("gaga");
		} */
		change($(this).val());
	});
	
	$("#money_out").focus(function(){
		copy($("#money_out").val());
	});
	
	function change(t) {
		if (t == "") {
			$("#money_out").val("");
			return;
		}
		//var patrn=/^(-)?(([1-9]{1}\d*)|([0]{1}))(\.(\d){1,2})?$/; 
		var patrn=/^(-)?(([1-9]{1}\d*)|([0]{1}))(\.(\d){1,2})?$/; 
		if(!patrn.exec(t)){
			$("#money_out").val("输入有误,不符合金额格式");
		} else {
			var ms = t.replace(/[^\\d\\.]/g, "").replace(/(\\.\\d{2}).+$/, "$1").replace(/^0+([1-9])/, "$1").replace(/^0+$/, "0");
			var ms = t;
			var txt = ms.split(".");
			while (/\\d{4}(,|$)/.test(txt[0])) txt[0] = txt[0].replace(/(\\d)(\\d{3}(,|$))/, "$1,$2");
			t = stmp = txt[0] + (txt.length > 1 ? "." + txt[1] : "");
			$("#money_out").val(number2CN(ms - 0, t));
		}
	}
	
	function number2CN(strg, obj) {
		var number = Math.round(strg * 100) / 100;
		number = number.toString(10).split(".");
		var a = number[0];
		if (a.length > 16) {
			obj = obj.substring(0, 16);
			return "太多了，还没见到过这么多钱。"
		} else {
			var e = "零壹贰叁肆伍陆柒捌玖";
			var num1 = "";
			var len = a.length - 1;
			for (var i = 0; i <= len; i++) num1 += e.charAt(parseInt(a.charAt(i))) + [["圆", "万", "亿","万"][Math.floor((len - i) / 4)], "拾", "佰", "仟"][(len - i) % 4];
			if (number.length == 2 && number[1] != "") {
				var a = number[1];
				for (var i = 0; i < a.length; i++) num1 += e.charAt(parseInt(a.charAt(i))) + ["角", "分"][i]
			}
			num1 = num1.replace(/零佰|零拾|零仟|零角/g, "零");
			num1 = num1.replace(/零{2,}/g, "零");
			num1 = num1.replace(/零(?=圆|万|亿)/g, "");
			num1 = num1.replace(/亿万/, "亿");
			num1 = num1.replace(/^圆零?/, "");
			if (num1 != "" && !/分$/.test(num1)) num1 += "整";
			return num1;
		}
	}
});


function copy(txt)
{
	if (window.clipboardData)
	{
		window.clipboardData.setData("Text",txt);
	}
	else
	{
		txt = encodeURIComponent(txt);
		var flashcopier = 'flashcopier';
		if(!document.getElementById(flashcopier))
		{
			var divholder = document.createElement('div');
			divholder.id = flashcopier;
			document.body.appendChild(divholder);
		}
		document.getElementById(flashcopier).innerHTML = '';
		var divinfo = "<embed src='<c:url value='/js/clipboard.swf'/>' flashvars='clipboard='"+txt+"'' type='application/x-shockwave-flash' width='0' height='0'></embed>";
		document.getElementById(flashcopier).innerHTML = divinfo;
		alert(document.getElementById(flashcopier).innerHTML);
	}

	alert("复制成功");
}

document.oncontextmenu = new Function("event.returnValue=false");
function gGetElementById(s) {
	var o = (document.getElementById ? document.getElementById(s) : document.all[s]);
	return ((o == null) ? false: o)
}
var stmp = "";

function save() {
	gGetElementById("bbb").select();
	try {
		gGetElementById("bbb").createTextRange().execCommand("copy");
		gGetElementById("info").innerHTML = "已经复制到剪贴板，您可以直接粘贴到需要的文件中。"
	} catch(ex) {
		gGetElementById("info").innerHTML = "请按Ctrl+c键拷贝内容"
	}
}
</script>
</head>
<body>
	<div id="forex">
    	<div class="forex_cup">
        	<div id="forex_cp">
       	  <div class="forex_container" id="forex_container">
          	
          	<div id="forex_title"><img src="<c:url value="/images/app/qihoo/moneyChange/title.gif"/>"/></div>
            <div class="spaceCss"></div>
            <div id="forex_main">
            	<form>
                	<div class="forex_line">
                    	<div><span>输入金额：</span></div>
                        <div><input id="money_in" maxlength="30" style="font-family: arial; border: 1px solid rgb(124, 158, 206);" type="text"/><span style="color:red;">*</span></div>
                    </div>
                    <div class="forex_line">
                    	<div><span>大写金额：</span></div>
                        <div><input id="money_out" maxlength="30" style="font-family: arial; border: 1px solid rgb(124, 158, 206);" type="text"/></div>
                    </div>
            	</form>
            </div>
            <div class="spaceCss"></div>
            <div class="bottom">Powered by <a href="http://www.seemsea.com" target="_blank" title="Powered by Seemsea">Seemsea.com</a></div>
          </div>
          	</div>
        </div>
    </div>
    <div id="flashcopier"></div>
</body>
</html>